import request from '@/utils/request'

export const getSimpleUserList = () => request({
  url: '/sys/user/simple'
})

export const getUserListApi = (page, size) => request({
  url: '/sys/user',
  params: {
    page,
    size
  }
})

export const delEmployeeApi = id => request({
  url: `/sys/user/${id}`,
  method: 'delete'
})

export const addEmployeeApi = data => request({
  url: '/sys/user',
  method: 'post',
  data
})

export const batchEmployeeApi = data => request({
  url: '/sys/user/batch',
  method: 'post',
  data
})

export const saveUserDetailByIdApi = data => request({
  method: 'put',
  url: `/sys/user/${data.id}`,
  data
})

export const getPersonalDetailApi = id => request({
  url: `/employees/${id}/personalInfo`

})

/** *
 *  更新用户详情的基础信息
 * **/
export function updatePersonal(data) {
  return request({
    url: `/employees/${data.userId}/personalInfo`,
    method: 'put',
    data
  })
}

/** **
 * 获取用户的岗位信息
 *
 * ****/
export const getJobDetail = id => request({
  url: `/employees/${id}/jobs`
})

/**
 * 保存岗位信息
 * ****/
export const updateJob = data => request({
  url: `/employees/${data.userId}/jobs`,
  method: 'put',
  data
})

export const assignRolesApi = data => request({
  url: '/sys/user/assignRoles',
  method: 'put',
  data
})
